package com.策略模式2;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2022/10/27 13:35
 * @description:
 * @version:
 */
public enum EnumDemo {
    FIRST("001","第一个"),
    SECOND("002","第二个");

    private final String code;
    private final String desc;

    EnumDemo(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static EnumDemo getByCode(String code){
        if (code == null){
            return null;
        }
        for (EnumDemo value : EnumDemo.values()) {
            if (value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
